const BASE_URL = "http://localhost:8080"
export const myRequest = (options) => {
	return new Promise((resolver, reject) => {
		uni.request({
			url: BASE_URL + options.url,
			method: options.method || 'GET',
			//todo header
			data: options.data || {},
			header: {
				"Authorization": `Bearer ${options.token}`
			},
			success: (res) => {
				if (res.data.code === 20001) {
					return uni.showToast({
						title: "获取数据失败"
					})
				}
				resolver(res)
			},
			fail: (err) => {
				uni.showToast({
					title: "请求接口失败"
				})

				reject(err)
			}
		})
	})
}
